import axios from "axios";
import qs from "qs";

//用来发送网络请求的模块
function get(url, params) {
    return axios.get(url, {params});
}



//post请求序列化
function post(url, data) {
    return axios.post(url, qs.stringify(data));
}

function postToken(url,data) {


    return axios.post(url,qs.stringify(data),{headers:{token:localStorage.getItem("token")}})
}

export {
    get,//用于get请求
    post,//用于post请求
    postToken
}

//加载
// let loadingInstance = null;
axios.interceptors.request.use(
    config => {
       // loadingInstance = Loading.service({ fullscreen: true,text:"拼命加载中" });
        return config;
    },error => {
        console.info(error);
    }
);
//响应拦截器,处理掉多余的字段
axios.interceptors.response.use(
    response => {
        // loadingInstance.close();
        return response.data;
    },
    error => {
        console.info(error);
        return new Promise(() => {
        });
    }
);
// ---未完善用到出现问题再说。。。。
